﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using KaroInterface;

namespace Emerald
{

    public class Game
    {
        #region Members

        private IPlayer player1;
        private IPlayer player2;

        private GameState gamestate;

        public EColor ColorToPlay
        {
            get { return gamestate.ColorToPlay; }
        }


        public IPlayer PlayerToPlay
        {
            get
            {
                if (ColorToPlay == (EColor) Enum.Parse(typeof(EColor), player1.SColor))
                    return player1;
                return player2;
            }
        }

        public GameState GameState
        {
            get
            {
                return gamestate;
            }
        }

        #endregion

        #region Events
        public event GameState.PlayerChangedEvent PlayerChanged
        {
            add { gamestate.PlayerChanged += value; }
            remove { gamestate.PlayerChanged -= value; }
        }
        public event GameState.GameEndedEvent GameEnded
        {
            add { gamestate.GameEnded += value; }
            remove { gamestate.GameEnded -= value; }
        }
        public event GameState.BoardChangedEvent BoardChanged
        {
            add { gamestate.BoardChanged += value; }
            remove { gamestate.BoardChanged -= value; }
        }
        #endregion

        #region Constructors

        public Game(IPlayer p1, IPlayer p2, EColor startingColor)
        {
            this.player1 = p1;
            this.player2 = p2;
            gamestate = new GameState(startingColor);
        }

        #endregion Constructors

        #region Methods

        public void Update(/* TODO : Unknown input params */)
        {
        }


        #endregion
    }
}
